<?php Yii::app()->clientScript->beginScript('custom-script'); ?>
<script type="text/javascript">
    function generateBarcode(code){
        var value = code;
        var btype = 'code128';
        var renderer = 'css';

        var settings = {
            output:renderer,
            bgColor: '#FFFFFF',
            color: '#000000',
            barWidth: 1,
            barHeight: 50
        };
        $("#img-barcode").html("").show().barcode(value, btype, settings);
    }
    $(document).ready(function() {
        generateBarcode('<?php echo $model->id_by_matter; ?>');
    });
</script>
<?php Yii::app()->clientScript->endScript();?>
<?php
$flashMessages = Yii::app()->user->getFlashes();
if ($flashMessages) {
    foreach($flashMessages as $key => $message) {
        echo '<div class="alert alert-' . $key . ' fade in"><button type="button" class="close" data-dismiss="alert">×</button>' . $message . "</div>\n";
    }
}
?>

<div id="yw0">
    <a class="btn-back pull-right" href="<?php echo $this->createUrl('user/taskuser')?>">← <?php echo Yii::t('app', 'Back to task list') ?></a>
    <ul id="yw1" class="nav nav-tabs">
        <li class=""><a data-toggle="tab" href="#yw0_tab_1"><?php echo Yii::t('app', 'View task') ?></a></li>
        <li class="active"><a data-toggle="tab" href="#yw0_tab_2"><?php echo Yii::t('app', 'Steps analyst') ?></a></li>
    </ul>
    <div class="tab-content">
        <div id="yw0_tab_1" class="tab-pane fade">
            <fieldset>
                <legend>
                    <?php echo Yii::t('app', 'View task detail') ?>
                </legend>
                <?php
                $this->widget('bootstrap.widgets.TbDetailView', array(
                    'data'=>$data,
                    'attributes'=>array(
                        array('name'=>'attribute_matter', 'label'=>Yii::t('app', 'Matter name')),
                        array('name'=>'content_matter', 'label'=>Yii::t('app', 'Matter content')),
                        array('name'=>'status', 'label'=>Yii::t('app', 'Status')),
                        array('name'=>'deadline', 'label'=>Yii::t('app', 'Deadline')),

                    ),
                ));
                ?>

            </fieldset>
        </div>

        <div id="yw0_tab_2" class="tab-pane fade active in">
            <fieldset>
                <legend>
                    <?php echo Yii::t('app', 'Steps analyst') ?>
                </legend>
				<div class="pull-right">
					<div id="img-barcode"></div>
					&nbsp;&nbsp;&nbsp;&nbsp;
					<?php $image = CHtml::image(Yii::app()->getBaseUrl().'/images/print.png', ''); ?>
					<?php //echo CHtml::link($image, $this->createUrl('task/print', array('c'=>$model->id_by_matter)), array('id'=>'print-url', 'target'=> '_blank')) ?>
				</div>
                <?php $form=$this->beginWidget('CActiveForm', array(
                    'id'=>'task-analyst-form',
//                    'action'=>Yii::app()->createUrl('user/userstt'),
                    'enableAjaxValidation'=>false
                ));
                ?>
                <div class="pull-right btn-toolbar inline">
                    <?php echo CHtml::dropDownList('status', '', Constant::getStatusUser(), array(
                        'empty'=>'',
                        'style' => 'margin-bottom:0px; margin-right:10px;width:130px;',
                    ))?>
                    <?php
                    $this->widget('bootstrap.widgets.TbButton', array(
                        'buttonType' => 'submit',
                        'type' => 'info',
                        'label' => Yii::t('app', 'Change status steps'),
                        'icon' => 'check white'
                    ));
                    ?>
                </div>
                <?php
                //    $this->widget('zii.widgets.grid.CGridView', array(
                $this->widget('bootstrap.widgets.TbGridView', array(
                    'id'=> 'task',
                    'dataProvider'=>$modelTaskAnalyst->search_task($model->id_task),
                    'enableSorting' => false,
                    'type' => 'striped',
                    'summaryText' => '',
                    'columns'=>array(
                        array(
                            'value'=>'$data->id_task_analyst',
                            'class'=>'CCheckBoxColumn',
                            'selectableRows' => 2,
                            'checkBoxHtmlOptions' => array(
                                'name' => 'ids[]',
                            ),
                        ),
                        'step_analyst',
                        array(
                            'name' => 'date_add',
                            'value'=> 'date("Y-m-d", strtotime($data->date_add))',
                        ),

                        array(
                            'name' => 'status',
                            'value'=> 'Common::getValue($data->status, Constant::getStatus())',
                            'cssClassExpression'=>'"hnx-".Constant::getStatustag($data->status)',
                        ),

                        array(
                            'name' => 'quantity',
                            'value'=> 'isset($data->analyst_special->quantity) ? $data->analyst_special->quantity : ""',
                        ),

                        array(
                            'class'=>'bootstrap.widgets.TbButtonColumn',
                            'template' => '{updatestatus}',
                            'htmlOptions' => array('width'=>'150', 'align'=>'center'),
                            'buttons'=>array(
                                'updatestatus' => array(
                                    'visible'=>'$data->status!=Constant::STATUS_CLOSE',
                                    'label'=>Yii::t('app', 'Update status step'),
                                    'icon'=>'pencil',
                                    'url'=>'Yii::app()->createUrl("user/stepstatus", array("id"=>$data->id_task_analyst, "t"=>$data->id_task))',
                                    'options'=>array(
                                        'class'=>'view-action',
                                    ),
                                ),
                            ),
                        ),


                    ),
                ));
                ?>
                <?php $this->endWidget(); ?>
            </fieldset>
        </div>

    </div>

</div>
